package com.kyomonn.talkischeap;

import android.os.Bundle;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.fragment.app.FragmentTransaction;

import com.kyomonn.talkischeap.CodingResources.CodingResourcesFragment;
import com.kyomonn.talkischeap.DeepSeek.DeepSeekFragment;
import com.kyomonn.talkischeap.PersonalCenter.PersonalCenterFragment;
import com.kyomonn.talkischeap.QuestionBank.QuestionBankFragment;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.activity_main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        DeepSeekFragment deepSeekFragment = DeepSeekFragment.Create();
        findViewById(R.id.btn_fragment_deepseek).setOnClickListener(v -> {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.fragment_container_view, deepSeekFragment);
            transaction.commit();
        });

        CodingResourcesFragment codingResourcesFragment = CodingResourcesFragment.Create();
        findViewById(R.id.btn_fragment_coding_resource).setOnClickListener(v -> {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.fragment_container_view, codingResourcesFragment);
            transaction.commit();
        });

        QuestionBankFragment questionBankFragment = QuestionBankFragment.Create();
        findViewById(R.id.btn_fragment_online_question_bank).setOnClickListener(v -> {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.fragment_container_view, questionBankFragment);
            transaction.commit();
        });

        PersonalCenterFragment personalCenterFragment = PersonalCenterFragment.Create();
        findViewById(R.id.btn_fragment_personal_center).setOnClickListener(v -> {
            FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
            transaction.replace(R.id.fragment_container_view, personalCenterFragment);
            transaction.commit();
        });

        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
        transaction.replace(R.id.fragment_container_view, codingResourcesFragment);
        transaction.commit();
    }
}